package com.example.administrator.mxh.fragment;

import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;

import com.example.administrator.mxh.R;

public class AdBannerFragment extends Fragment {
    private ImageView iv;
    private String ab;

    public static AdBannerFragment newInstance(Bundle bundle){
        AdBannerFragment af=new AdBannerFragment();
        af.setArguments(bundle);
        return af;
    }
    @Override
    public void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        Bundle arg=getArguments();
        ab=arg.getString("ad");
    }
    @Override
    public void onResume() {
        super.onResume();
        if(ab.equals("banner_1")){
            iv.setImageResource(R.drawable.banner_1);
        }else if(ab.equals("banner_2")){
            iv.setImageResource(R.drawable.banner_2);
        }else if(ab.equals("banner_3")){
            iv.setImageResource(R.drawable.banner_3);
        }
    }
    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        iv=new ImageView(getContext());
        iv.setScaleType(ImageView.ScaleType.FIT_XY);
        return iv;
    }
}
